// Copyright (C) ZHENG Zhong <heavyzheng nospam-at gmail D0T com>
//
// $Id: types.hpp 317 2009-01-12 11:10:14Z heavyzheng $
//

#ifndef ZZHENG_XML_DOM_TYPES_HPP_20080703__
#define ZZHENG_XML_DOM_TYPES_HPP_20080703__

#include <zzheng/xml/config.hpp>
#include <string>

namespace zzheng {
namespace xml {
namespace dom {

    //! The size type used to count nodes.
    typedef unsigned int size_type;

    //! The XML node type enumerations.
    enum node_t {
        unknown_node = 0,
        attribute_node,
        element_node,
        text_node,
        cdata_node,
        comment_node,
    }; // enum node_t

    //! The XPath result type enumerations.
    enum xpath_result_t {
        xpath_undefined = 0, //!< Undefined data type.
        xpath_boolean,       //!< XPath 1.0 boolean data type.
        xpath_number,        //!< XPath 1.0 number data type.
        xpath_string,        //!< XPath 1.0 string data type.
        xpath_node_set,      //!< XPath 1.0 node set data type.
    }; // enum xpath_result_t

    //! Enumerations indicating if an action is to adopt the node (transfer the ownership) or to
    //! clone the node. This enum is used in XML node operations on two DOM trees.
    enum adopt_or_clone_t {
        adopt_node = 0, //!< Adopt node from the source DOM tree (thus transfer node ownership).
        clone_node,     //!< Clone node and do not change node ownership.
    }; // enum adopt_or_clone_t

    ////////////////////////////////////////////////////////////////////////////////////////////////

    inline
    std::string to_string(node_t type) {
        switch (type) {
        case element_node:
            return "element";
        case attribute_node:
            return "attribute";
        case text_node:
            return "text";
        case cdata_node:
            return "cdata";
        case comment_node:
            return "comment";
        default:
            return "unknown";
        }
    }

} // namespace zzheng::xml::dom
} // namespace zzheng::xml
} // namespace zzheng

#endif // ZZHENG_XML_DOM_NODE_TYPE_HPP_20080703__



